'use strict';

module.exports = {
  async up (queryInterface, Sequelize) {
    const { INTEGER,DATE } = Sequelize;
    await queryInterface.createTable('moment_like', {
      id:{
        type: INTEGER(20).UNSIGNED, 
        primaryKey: true, 
        autoIncrement: true
      },
      user_id:{
        type: INTEGER(20).UNSIGNED, 
        allowNull: false, 
        comment: "点赞用户id",
        // 外键
        references: {
          model: 'user',
          key: 'id'
        },
        onUpdate: 'restrict', // 更新时操作
        onDelete: 'cascade' // 删除时操作
      },
      moment_id: {
        type: INTEGER(20).UNSIGNED, 
        allowNull: false,
        comment: "朋友圈消息id",
        // 外键
        references: {
          model: 'moment',
          key: 'id'
        },
        onUpdate: 'restrict', // 更新时操作
        onDelete: 'cascade' // 删除时操作
      },
      created_at: DATE,
      updated_at: DATE
    })
  },

  async down (queryInterface, Sequelize) {
    await queryInterface.dropTable('moment_like')
  }
};
